import request from './requests.js'
import qs from 'qs'
import Cookies from 'js-cookie'
import {
	select_all_sku_url,
	select_all_sku_by_duty_id_url
} from "./setting.js"

import {
	Toast
} from 'vant'

import {
	getLocalTime
} from "./date.js"



function select_all_sku_(callBack) {


		request({
			method: 'GET',
			url: select_all_sku_url,
			
		}).then((response) => { //这里使用了ES6的语法
	
			let sku_list = response.data.resultBody
			for (var i = 0; i < sku_list.length; i++) {
				let val = sku_list[i]['spu_name'] +
					' ' +
					'|商标:' + sku_list[i]['brand_name'] +
					'|父类:' + sku_list[i]['parent_name'] +
					'|子类:' + sku_list[i]['class_name']
	
				sku_list[i]['value'] = val
			}
	
			// console.log(sku_list)
			callBack(sku_list)
		}).catch((error) => {
			console.log(error)
			Toast('远程接口故障请联系管理员！！')
	

		})


}


function select_all_sku(callBack) {


		request({
			method: 'POST',
			url: select_all_sku_by_duty_id_url,
			data: qs.stringify({ //这里是发送给后台的数据
				duty_id: Cookies.get('duty_id')
			})
		}).then((response) => { //这里使用了ES6的语法
	
			let sku_list = response.data.resultBody.reverse()
			for (var i = 0; i < sku_list.length; i++) {
				let val = sku_list[i]['spu_name'] +
					' ' +
					'|商标:' + sku_list[i]['brand_name'] +
					'|父类:' + sku_list[i]['parent_name'] +
					'|子类:' + sku_list[i]['class_name']
	
				sku_list[i]['value'] = val
			}
	
			// console.log(sku_list)
			callBack(sku_list)
		}).catch((error) => {
			console.log(error)
			Toast('远程接口故障请联系管理员！！')
	

		})


}





export default select_all_sku
